// EcoModeler - C# Edition :: Version 9.17 build 3378
using System;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using Eco.Services;
using Eco.ObjectRepresentation;
using Eco.ObjectImplementation;
using Eco.UmlRt;
using Eco.UmlCodeAttributes;
using Eco.Subscription;
using EcoExtensions.Model;

using Axiom.Core;
using Axiom.Math;

namespace VisualDM.Model
{
	#region MM_ECO_Generated
	#region Attributes
	[UmlElement(Id="{802946cf-50f5-4f63-9860-6d08aa11b51b}")]
	#endregion

	#endregion
	public class DirectionalLightSceneObject: SceneObject
	{
		#region MM_ECO AutoGenerated ECO code

		new public struct Eco_LoopbackIndices
		{
			public const int Eco_FirstMember = VisualDM.Model.SceneObject.Eco_LoopbackIndices.Eco_MemberCount;
			public const int Eco_MemberCount = (Eco_FirstMember + 4);
			public const int Color_MemberIndex = Eco_FirstMember + 0;
			public const int Diffuse_MemberIndex = Eco_FirstMember + 1;
			public const int Direction_MemberIndex = Eco_FirstMember + 2;
			public const int Specular_MemberIndex = Eco_FirstMember + 3;
		}
		#endregion

		#region MM_ECO Model owned attributes
		//Note: Do not remove any property within this region, nor change its signature

		#region MM_ECO_Generated
		[UmlElement("AssociationEnd", Index=(DirectionalLightSceneObject.Eco_LoopbackIndices.Direction_MemberIndex), Id="{dbc9f952-90cc-4402-b014-a6e35bb45ef5}")]
		[UmlMetaAttribute("association", typeof(VisualDMPackage.DirectionalLightSceneObjectEcoVector), Index=1)]
		[UmlMetaAttribute("multiplicity", "1")]
		#endregion
		public EcoVector Direction
		{
			get
			{
				#region MM_ECO_Generated
				return (EcoVector) (this.eco_Content.get_MemberByIndex(Eco_LoopbackIndices.Direction_MemberIndex));
				#endregion
			}
			set
			{
				#region MM_ECO_Generated
				this.eco_Content.set_MemberByIndex(Eco_LoopbackIndices.Direction_MemberIndex, ((object)(value)));
				#endregion
			}
		}


		#region MM_ECO_Generated
		[UmlElement("AssociationEnd", Index=(DirectionalLightSceneObject.Eco_LoopbackIndices.Color_MemberIndex), Id="{61cc2a23-fe0d-464e-b3b5-40436c0d8dc0}")]
		[UmlMetaAttribute("association", typeof(VisualDMPackage.DirectionalLightSceneObjectEcoColorEx), Index=1)]
		[UmlMetaAttribute("multiplicity", "1")]
		[UmlTaggedValue("Eco.Embed", "True")]
		#endregion
		public EcoColorEx Color
		{
			get
			{
				#region MM_ECO_Generated
				return (EcoColorEx) (this.eco_Content.get_MemberByIndex(Eco_LoopbackIndices.Color_MemberIndex));
				#endregion
			}
			set
			{
				#region MM_ECO_Generated
				this.eco_Content.set_MemberByIndex(Eco_LoopbackIndices.Color_MemberIndex, ((object)(value)));
				#endregion
			}
		}

		#region MM_ECO_Generated
		[UmlElement("AssociationEnd", Index=(DirectionalLightSceneObject.Eco_LoopbackIndices.Diffuse_MemberIndex), Id="{fde769af-c326-40e2-8ba4-20ccd2d46697}")]
		[UmlMetaAttribute("association", typeof(VisualDMPackage.DirectionalLightSceneObjectEcoColorEx1), Index=1)]
		[UmlMetaAttribute("multiplicity", "1")]
		#endregion
		public EcoColorEx Diffuse
		{
			get
			{
				#region MM_ECO_Generated
				return (EcoColorEx) (this.eco_Content.get_MemberByIndex(Eco_LoopbackIndices.Diffuse_MemberIndex));
				#endregion
			}
			set
			{
				#region MM_ECO_Generated
				this.eco_Content.set_MemberByIndex(Eco_LoopbackIndices.Diffuse_MemberIndex, ((object)(value)));
				#endregion
			}
		}

		#region MM_ECO_Generated
		[UmlElement("AssociationEnd", Index=(DirectionalLightSceneObject.Eco_LoopbackIndices.Specular_MemberIndex), Id="{688cddbd-b5ec-4da2-9873-374c5efaace3}")]
		[UmlMetaAttribute("association", typeof(VisualDMPackage.DirectionalLightSceneObjectEcoColorEx2), Index=1)]
		[UmlMetaAttribute("multiplicity", "1")]
		#endregion
		public EcoColorEx Specular
		{
			get
			{
				#region MM_ECO_Generated
				return (EcoColorEx) (this.eco_Content.get_MemberByIndex(Eco_LoopbackIndices.Specular_MemberIndex));
				#endregion
			}
			set
			{
				#region MM_ECO_Generated
				this.eco_Content.set_MemberByIndex(Eco_LoopbackIndices.Specular_MemberIndex, ((object)(value)));
				#endregion
			}
		}
		#endregion

		#region MM_ECO Model owned methods
		//Note: Do not remove any method within this region, nor change its signature

		public DirectionalLightSceneObject(IContent content) : base(content)
		{
			#region MM_ECO_Generated
			#endregion
		}

		public DirectionalLightSceneObject(IEcoServiceProvider serviceProvider) : base(serviceProvider)
		{
			try
			{
				// Place user code ONLY here
				Diffuse = new EcoColorEx(serviceProvider);
				Color = new EcoColorEx(serviceProvider);
				Specular = new EcoColorEx(serviceProvider);
				Direction = new EcoVector(serviceProvider);

			}
			catch (System.Exception)
			{
				this.Deinitialize(serviceProvider);
				throw;
			}
		}
		#endregion

        public Light light;

        public override void Initialize(SceneNode node, SceneManager sm, bool reset)
        {
            base.Initialize(node, sm,false);
            if (light==null)
            {
                light = sm.CreateLight(Name);
                light.Type = Axiom.Graphics.LightType.Directional;
            }
            light.Position = new Vector3(DefaultPosition.Vector.x, DefaultPosition.Vector.y, DefaultPosition.Vector.z);
            light.Direction = Direction.Vector;
            light.Diffuse = Diffuse.Color;
//            light.Specular = Specular.Color;
        }

        public void SetAttenuation(float range, float constant, float linear, float quadratic)
        {
            if (light != null)
                light.SetAttenuation(range, constant, linear, quadratic);
        }

        public override void RollBack()
        {
        }

        public override void SetCheckPoint()
        {
        }
	}
}
